package tw.asap.plus.ui.activity;

import android.app.Activity;
import android.content.Intent;
import android.content.IntentSender;
import android.location.Address;
import android.location.Geocoder;
import android.location.Location;
import android.os.Bundle;
import android.os.Handler;
import android.os.ResultReceiver;
import android.support.v4.app.FragmentTransaction;
import android.text.TextUtils;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.Toast;

import com.amap.api.location.AMapLocation;
import com.amap.api.location.AMapLocationClient;
import com.amap.api.location.AMapLocationClientOption;
import com.amap.api.location.AMapLocationListener;
import com.baidu.location.BDLocation;
import com.baidu.location.BDLocationListener;
import com.baidu.location.LocationClient;
import com.baidu.location.LocationClientOption;
import com.baidu.location.Poi;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.common.api.PendingResult;
import com.google.android.gms.common.api.ResultCallback;
import com.google.android.gms.common.api.Status;
import com.google.android.gms.location.LocationRequest;
import com.google.android.gms.location.LocationServices;
import com.google.android.gms.location.LocationSettingsRequest;
import com.google.android.gms.location.LocationSettingsResult;
import com.google.android.gms.location.LocationSettingsStates;
import com.google.android.gms.location.LocationSettingsStatusCodes;
import com.google.android.gms.location.places.Place;
import com.google.android.gms.location.places.PlaceLikelihood;
import com.google.android.gms.location.places.PlaceLikelihoodBuffer;
import com.google.android.gms.location.places.Places;

import java.util.ArrayList;
import java.util.List;

import butterknife.ButterKnife;
import butterknife.InjectView;
import tw.asap.plus.R;
import tw.asap.plus.common.ConstValue;
import tw.asap.plus.entity.LocationBean;
import tw.asap.plus.service.FetchAddressIntentService;
import tw.asap.plus.ui.AsapBaseActivity;
import tw.asap.plus.ui.fragment.HomeTabFragment;
import tw.asap.plus.utils.LocateUtil;
import tw.asap.plus.utils.SPUtil;
import tw.asap.plus.utils.T;
import tw.asap.plus.utils.Toaster;

public class MainActivity extends AsapBaseActivity implements View.OnClickListener, GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener {


    private static final String TAG = "MainActivity";
    @InjectView(R.id.main_tab_content)
    FrameLayout contentLayout;

    @InjectView(R.id.main_tab_host)
    FrameLayout main_tab_host;

    GoogleApiClient mGoogleApiClient;

    private HomeTabFragment mTabFragment;

    private Location mLastLocation;

    private AddressResultReceiver mResultReceiver;

    private boolean mAddressRequested;

    private String mAddressOutput;
    private Address mAddress;
    private Place mPlace;
    private LocationBean mLocation;

    private static final int REQUEST_CHECK_SETTINGS = 0x0100;
    public static final int REQUEST_FOR_LOCATION = 0x0101;

    public static int REFRESH_ALL_FRAGMENT = 0;
    public static int REFRESH_ORDER_LIST = 0;
    public static int RESUME_ACTION = 0;

    public static final int MAX_COUNT_GET_LOCATION = 3;
    List<LocationListener> locationListenerList = null;
    int tryTime = 0;

    //声明AMapLocationClient类对象
    public AMapLocationClient mLocationClient = null;
    //声明定位回调监听器
    public AMapLocationListener mLocationListener = null;
    //声明mLocationOption对象
    public AMapLocationClientOption mLocationOption = null;

    public LocationClient mBaiduLocationClient = null;
    public BDLocationListener mBaiduListener = null;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ButterKnife.inject(this);
        initialize();
    }

    //初始化方法
    private void initialize() {
//        initAmapApiClient();
//        initGoogleApiClient();
        initBaiduApiClient();
        showTabFragment();
    }

    @Override
    protected void onStart() {
        super.onStart();
//        mGoogleApiClient.connect();
        //启动定位
//        if (!mAddressRequested) {
//            mLocationClient.startLocation();
//        }
        if (!mAddressRequested) {
            mBaiduLocationClient.start();
        }
    }

    @Override
    protected void onStop() {
        super.onStop();
//        mGoogleApiClient.disconnect();
        //启动定位
//        mLocationClient.stopLocation();
        mBaiduLocationClient.stop();
    }

    private void initAmapApiClient() {
        mLocationListener = new AMapLocationListener() {
            @Override
            public void onLocationChanged(AMapLocation aMapLocation) {
                if (aMapLocation != null) {
                    if (aMapLocation.getErrorCode() == 0) {
                        //定位成功回调信息，设置相关消息
                        T.i("AmapLocation: " + aMapLocation.toString());

                        mLocation = new LocationBean();
                        mLocation.latitude = String.valueOf(aMapLocation.getLatitude());
                        mLocation.longitude = String.valueOf(aMapLocation.getLongitude());
                        mLocation.address = aMapLocation.getAddress();
                        String address = aMapLocation.getExtras().getString("desc");
                        if (address != null && address.contains(" ")) {
                            String[] spliteAddr = address.split(" ");
                            mLocation.name = spliteAddr[spliteAddr.length - 2].concat(spliteAddr[spliteAddr.length - 1]);
                        } else {
                            mLocation.name = aMapLocation.getAddress();
                        }
                        if (locationListenerList != null)
                            for (LocationListener mListener : locationListenerList) {
                                mListener.onGetLatLon(mLocation);
                            }
                        displayAddressOutput();
                        mAddressRequested = true;
                        mLocationClient.stopLocation();
                    } else {
                        //显示错误信息ErrCode是错误码，errInfo是错误信息，详见错误码表。
                        Log.e("AmapError", "location Error, ErrCode:"
                                + aMapLocation.getErrorCode() + ", errInfo:"
                                + aMapLocation.getErrorInfo());
                    }
                }
            }
        };
        //初始化定位
        mLocationClient = new AMapLocationClient(getApplicationContext());
        //设置定位回调监听
        mLocationClient.setLocationListener(mLocationListener);
        //初始化定位参数
        mLocationOption = new AMapLocationClientOption();
        //设置定位模式为高精度模式，Battery_Saving为低功耗模式，Device_Sensors是仅设备模式
        mLocationOption.setLocationMode(AMapLocationClientOption.AMapLocationMode.Hight_Accuracy);
        //设置是否返回地址信息（默认返回地址信息）
        mLocationOption.setNeedAddress(true);
        //设置是否只定位一次,默认为false
        mLocationOption.setOnceLocation(false);
        //设置是否强制刷新WIFI，默认为强制刷新
        mLocationOption.setWifiActiveScan(true);
        //设置是否允许模拟位置,默认为false，不允许模拟位置
        mLocationOption.setMockEnable(false);
        //设置定位间隔,单位毫秒,默认为2000ms
        mLocationOption.setInterval(20000);
        //给定位客户端对象设置定位参数
        mLocationClient.setLocationOption(mLocationOption);
    }

    private void initBaiduApiClient() {
        mBaiduLocationClient = new LocationClient(getApplicationContext());     //声明LocationClient类
        mBaiduListener = new BDLocationListener() {
            @Override
            public void onReceiveLocation(BDLocation bdLocation) {
                StringBuffer sb = new StringBuffer(256);
                sb.append("time : ");
                sb.append(bdLocation.getTime());
                sb.append("\nerror code : ");
                sb.append(bdLocation.getLocType());
                sb.append("\nlatitude : ");
                sb.append(bdLocation.getLatitude());
                sb.append("\nlontitude : ");
                sb.append(bdLocation.getLongitude());
                sb.append("\nradius : ");
                sb.append(bdLocation.getRadius());
                if (bdLocation.getLocType() == BDLocation.TypeGpsLocation) {// GPS定位结果
                    sb.append("\nspeed : ");
                    sb.append(bdLocation.getSpeed());// 单位：公里每小时
                    sb.append("\nsatellite : ");
                    sb.append(bdLocation.getSatelliteNumber());
                    sb.append("\nheight : ");
                    sb.append(bdLocation.getAltitude());// 单位：米
                    sb.append("\ndirection : ");
                    sb.append(bdLocation.getDirection());// 单位度
                    sb.append("\naddr : ");
                    sb.append(bdLocation.getAddrStr());
                    sb.append("\ndescribe : ");
                    sb.append("gps定位成功");

                } else if (bdLocation.getLocType() == BDLocation.TypeNetWorkLocation) {// 网络定位结果
                    sb.append("\naddr : ");
                    sb.append(bdLocation.getAddrStr());
                    //运营商信息
                    sb.append("\noperationers : ");
                    sb.append(bdLocation.getOperators());
                    sb.append("\ndescribe : ");
                    sb.append("网络定位成功");
                } else if (bdLocation.getLocType() == BDLocation.TypeOffLineLocation) {// 离线定位结果
                    sb.append("\ndescribe : ");
                    sb.append("离线定位成功，离线定位结果也是有效的");
                } else if (bdLocation.getLocType() == BDLocation.TypeServerError) {
                    sb.append("\ndescribe : ");
                    sb.append("服务端网络定位失败，可以反馈IMEI号和大体定位时间到loc-bugs@baidu.com，会有人追查原因");
                } else if (bdLocation.getLocType() == BDLocation.TypeNetWorkException) {
                    sb.append("\ndescribe : ");
                    sb.append("网络不同导致定位失败，请检查网络是否通畅");
                } else if (bdLocation.getLocType() == BDLocation.TypeCriteriaException) {
                    sb.append("\ndescribe : ");
                    sb.append("无法获取有效定位依据导致定位失败，一般是由于手机的原因，处于飞行模式下一般会造成这种结果，可以试着重启手机");
                }
                sb.append("\nlocationdescribe : ");
                sb.append(bdLocation.getLocationDescribe());// 位置语义化信息
                List<Poi> list = bdLocation.getPoiList();// POI数据
                if (list != null) {
                    sb.append("\npoilist size = : ");
                    sb.append(list.size());
                    for (Poi p : list) {
                        sb.append("\npoi= : ");
                        sb.append(p.getId() + " " + p.getName() + " " + p.getRank());
                    }
                }
                Log.i("BaiduLocationApiDem", sb.toString());

                if (bdLocation.getLocType() == BDLocation.TypeNetWorkLocation || bdLocation.getLocType() == BDLocation.TypeOffLineLocation
                        || bdLocation.getLocType() == BDLocation.TypeGpsLocation) {

                    mLocation = new LocationBean();
                    mLocation.latitude = String.valueOf(bdLocation.getLatitude());
                    mLocation.longitude = String.valueOf(bdLocation.getLongitude());
                    mLocation.address = bdLocation.getAddrStr();
//                    List<Poi> poiList = bdLocation.getPoiList();
//                    if (poiList != null && poiList.size() > 0) {// POI数据
//                        mLocation.name = poiList.get(0).getName();
//                    } else {
//                        mLocation.name = bdLocation.getAddrStr();
//                    }
                    mLocation.name = bdLocation.getAddrStr();
                    if (locationListenerList != null)
                        for (LocationListener mListener : locationListenerList) {
                            mListener.onGetLatLon(mLocation);
                        }
                    displayAddressOutput();
                    mAddressRequested = true;
                    mBaiduLocationClient.stop();
                }
            }
        };
        mBaiduLocationClient.registerLocationListener(mBaiduListener);    //注册监听函数
        LocationClientOption option = new LocationClientOption();
        option.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy
        );//可选，默认高精度，设置定位模式，高精度，低功耗，仅设备
//        option.setCoorType("bd09ll");//可选，默认gcj02，设置返回的定位结果坐标系
        option.setCoorType("gcj02");//可选，默认gcj02，设置返回的定位结果坐标系
        int span = 2000;
        option.setScanSpan(span);//可选，默认0，即仅定位一次，设置发起定位请求的间隔需要大于等于1000ms才是有效的
        option.setIsNeedAddress(true);//可选，设置是否需要地址信息，默认不需要
        option.setOpenGps(true);//可选，默认false,设置是否使用gps
        option.setLocationNotify(true);//可选，默认false，设置是否当gps有效时按照1S1次频率输出GPS结果
        option.setIsNeedLocationDescribe(true);//可选，默认false，设置是否需要位置语义化结果，可以在BDLocation.getLocationDescribe里得到，结果类似于“在北京天安门附近”
        option.setIsNeedLocationPoiList(true);//可选，默认false，设置是否需要POI结果，可以在BDLocation.getPoiList里得到
        option.setIgnoreKillProcess(false);//可选，默认false，定位SDK内部是一个SERVICE，并放到了独立进程，设置是否在stop的时候杀死这个进程，默认杀死
        option.SetIgnoreCacheException(false);//可选，默认false，设置是否收集CRASH信息，默认收集
        option.setEnableSimulateGps(false);//可选，默认false，设置是否需要过滤gps仿真结果，默认需要
        mBaiduLocationClient.setLocOption(option);
    }


    private void initGoogleApiClient() {
        mGoogleApiClient = new GoogleApiClient.Builder(this)
                .addConnectionCallbacks(this)
                .addApi(Places.GEO_DATA_API)
                .addApi(Places.PLACE_DETECTION_API)
                .addOnConnectionFailedListener(this)
                .addApi(LocationServices.API)
                .build();
    }

    public void showTabFragment() {
        mTabFragment = new HomeTabFragment();
        FragmentTransaction transaction = this.getSupportFragmentManager().beginTransaction();
        transaction.setCustomAnimations(R.anim.fragments_transition_in, R.anim.fragments_transition_out);
        transaction.replace(R.id.main_tab_host, mTabFragment);
        transaction.commit();
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }

    @Override
    public void onClick(View v) {
    }

    @Override
    protected void onResume() {
        super.onResume();
        if (RESUME_ACTION != 0)
            mTabFragment.setCurrentTab(RESUME_ACTION - 1);
        RESUME_ACTION = 0;
    }

//    public Parcelable getLastLocation() {
//        if (mAddress != null) {
//            return mAddress;
//        } else if (mLastLocation != null)
//            return mLastLocation;
//        return null;
//    }

    public LocationBean getLastLocation() {
        return mLocation;
    }

    protected void startIntentService() {

        if (mResultReceiver == null) {
            mResultReceiver = new AddressResultReceiver(new Handler());
        }
        Intent intent = new Intent(this, FetchAddressIntentService.class);
        intent.putExtra(ConstValue.RECEIVER, mResultReceiver);
        intent.putExtra(ConstValue.LOCATION_DATA_EXTRA, mLastLocation);
        startService(intent);
        mAddressRequested = true;
    }

    public void fetchAddressButtonHandler(View view) {
        // Only start the service to fetch the address if GoogleApiClient is
        // connected.
        if (mGoogleApiClient.isConnected() && mLastLocation != null) {
            startIntentService();
        }
        // If GoogleApiClient isn't connected, process the user's request by
        // setting mAddressRequested to true. Later, when GoogleApiClient connects,
        // launch the service to fetch the address. As far as the user is
        // concerned, pressing the Fetch Address button
        // immediately kicks off the process of getting the address.
        mAddressRequested = true;
        updateUIWidgets();
    }

    private void updateUIWidgets() {

    }

    public void unRegisterLocationListener(LocationListener mListener) {
        if (locationListenerList != null) {
            locationListenerList.remove(mListener);
        }
    }

    public void registerLocationListener(LocationListener mListener) {
        if (locationListenerList == null) {
            locationListenerList = new ArrayList<>();
        }
        locationListenerList.add(mListener);
    }

    @Override
    public void onConnected(Bundle bundle) {
        T.i("Google location: onConnected");
        checkLocationSetting();
    }

    private void checkLocationSetting() {
        LocationRequest locationRequest = LocationRequest.create();
        locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
        locationRequest.setInterval(30 * 1000);
        locationRequest.setFastestInterval(5 * 1000);

        LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder()
                .addLocationRequest(locationRequest);
        builder.setAlwaysShow(true);
        PendingResult<LocationSettingsResult> result =
                LocationServices.SettingsApi.checkLocationSettings(mGoogleApiClient, builder.build());
        result.setResultCallback(new ResultCallback<LocationSettingsResult>() {
            @Override
            public void onResult(LocationSettingsResult result) {
                final Status status = result.getStatus();
                final LocationSettingsStates state = result.getLocationSettingsStates();
                switch (status.getStatusCode()) {
                    case LocationSettingsStatusCodes.SUCCESS:
                        getMyCurrentPlace();
//                        getMyLocation();
                        break;
                    case LocationSettingsStatusCodes.RESOLUTION_REQUIRED:

                        try {
                            status.startResolutionForResult(
                                    MainActivity.this,
                                    REQUEST_CHECK_SETTINGS);
                        } catch (IntentSender.SendIntentException e) {
                            // Ignore the error.
                        }
                        break;
                    case LocationSettingsStatusCodes.SETTINGS_CHANGE_UNAVAILABLE:
                        // Location settings are not satisfied. However, we have no way to fix the
                        // settings so we won't show the dialog.
                        break;
                }
            }
        });
    }


    private void getMyLocation() {
        if (!mAddressRequested && tryTime < MAX_COUNT_GET_LOCATION) {
            mLastLocation = LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient);
            tryTime++;
            if (mLastLocation != null) {
                mLastLocation = LocateUtil.transformFromWGSToGCJ(mLastLocation);
                T.i("true location+++++++++++ : " + String.valueOf(mLastLocation.getLatitude()),
                        String.valueOf(mLastLocation.getLongitude()));

                SPUtil spUtil = SPUtil.getInstance(this);
                spUtil.save(ConstValue.Sp.LAT, String.valueOf(mLastLocation.getLatitude()));
                spUtil.save(ConstValue.Sp.LNG, String.valueOf(mLastLocation.getLongitude()));

                if (!Geocoder.isPresent()) {
                    Toast.makeText(this, R.string.no_geocoder_available,
                            Toast.LENGTH_LONG).show();
                    return;
                }
                startIntentService();
            } else {
                getMyLocation();
            }
        }
    }

    private void getMyCurrentPlace() {
        if (!mAddressRequested && tryTime < MAX_COUNT_GET_LOCATION) {
            PendingResult<PlaceLikelihoodBuffer> result = Places.PlaceDetectionApi
                    .getCurrentPlace(mGoogleApiClient, null);
            tryTime++;
            result.setResultCallback(new ResultCallback<PlaceLikelihoodBuffer>() {
                @Override
                public void onResult(PlaceLikelihoodBuffer likelyPlaces) {
                    for (PlaceLikelihood placeLikelihood : likelyPlaces) {
                        Log.i(TAG, String.format("Place '%s' has likelihood: %g",
                                placeLikelihood.getPlace().getName(),
                                placeLikelihood.getLikelihood()));
                    }
                    if (likelyPlaces.getCount() > 0) {
                        mAddressRequested = true;
                        Place currentPlace = likelyPlaces.get(0).getPlace().freeze();
                        likelyPlaces.release();
                        mPlace = currentPlace;
                        SPUtil.getInstance(MainActivity.this).save(ConstValue.Sp.LAT, String.valueOf(currentPlace.getLatLng().latitude));
                        SPUtil.getInstance(MainActivity.this).save(ConstValue.Sp.LNG, String.valueOf(currentPlace.getLatLng().longitude));

                        if (mLocation == null) {
                            mLocation = new LocationBean();
                        }
                        mLocation.address = mPlace.getAddress().toString();
                        mLocation.latitude = String.valueOf(mPlace.getLatLng().latitude);
                        mLocation.longitude = String.valueOf(mPlace.getLatLng().longitude);
                        mLocation.name = mPlace.getName().toString();
                        if (locationListenerList != null)
                            for (LocationListener mListener : locationListenerList) {
                                mListener.onGetLatLon(mLocation);
                            }

                        if (!Geocoder.isPresent()) {
                            Toast.makeText(MainActivity.this, R.string.no_geocoder_available,
                                    Toast.LENGTH_LONG).show();
                            return;
                        }
                        displayAddressOutput();
                    } else {
                        likelyPlaces.release();
                        Toaster.s(MainActivity.this, "获取位置失败,正在重试...");
                        getMyCurrentPlace();
                    }
                }
            });
        } else {
            mLocation = new LocationBean();
            mLocation.address = getString(R.string.unknow_location);
            mLocation.latitude = SPUtil.getInstance(this).getString(ConstValue.Sp.LAT, "0");
            mLocation.longitude = SPUtil.getInstance(this).getString(ConstValue.Sp.LNG, "0");
            mLocation.name = getString(R.string.unknow_location);
            if (locationListenerList != null)
                for (LocationListener mListener : locationListenerList) {
                    mListener.onGetLocationFailed();
                }
        }
    }


    @Override
    public void onConnectionSuspended(int i) {
        T.i("Google location: onConnectionSuspended");
    }

    @Override
    public void onConnectionFailed(ConnectionResult connectionResult) {
        T.i("Google location: onConnectionFailed");
        if (connectionResult.getErrorCode() == ConnectionResult.SERVICE_MISSING) {
            Toaster.s(this, getString(R.string.google_service_miss));
        }
        if (locationListenerList != null)
            for (LocationListener mListener : locationListenerList) {
                mListener.onGetLocationFailed();
            }
    }


    class AddressResultReceiver extends ResultReceiver {
        public AddressResultReceiver(Handler handler) {
            super(handler);
        }

        @Override
        protected void onReceiveResult(int resultCode, Bundle resultData) {
            T.i("Google location: onReceiveResult");
            // Display the address string
            // or an error message sent from the intent service.
            // Show a toast message if an address was found.
            if (resultCode == ConstValue.SUCCESS_RESULT) {
                mAddressOutput = resultData.getString(ConstValue.RESULT_DATA_KEY);
                mAddress = resultData.getParcelable(ConstValue.LOCATION_ADDRESS_EXTRA);
                mLocation = convertToLocation(mAddress);
                if (locationListenerList != null)
                    for (LocationListener mListener : locationListenerList) {
                        mListener.onGetLatLon(mLocation);
                    }
                displayAddressOutput();
                Toaster.s(MainActivity.this, getString(R.string.address_current).concat(mAddressOutput));
            } else {
                if (locationListenerList != null)
                    for (LocationListener mListener : locationListenerList) {
                        mListener.onGetLocationFailed();
                    }
            }

        }
    }

    private LocationBean convertToLocation(Address mAddress) {
        LocationBean locationBean = new LocationBean();
        locationBean.latitude = String.valueOf(mAddress.getLatitude());
        locationBean.longitude = String.valueOf(mAddress.getLongitude());
        locationBean.address = mAddress.getAddressLine(1);
        if (TextUtils.isEmpty(mAddress.getFeatureName()) || mAddress.getFeatureName().length() < 4) {
            locationBean.name = locationBean.address;
        } else {
            locationBean.name = mAddress.getFeatureName();
        }
        return locationBean;
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (mLocationClient != null)
            mLocationClient.onDestroy();
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        switch (requestCode) {
            case REQUEST_FOR_LOCATION:
                if (resultCode == RESULT_OK) {
                    mLocation = data.getParcelableExtra("LOCATION");
                    displayAddressOutput();
                }
                break;
            case REQUEST_CHECK_SETTINGS:
                switch (resultCode) {
                    case Activity.RESULT_OK:
                        getMyCurrentPlace();
                        break;
                    case Activity.RESULT_CANCELED:
                        checkLocationSetting();
                        break;
                }
                break;
        }
    }

    private void displayAddressOutput() {
        if (locationListenerList != null)
            for (LocationListener mListener : locationListenerList) {
                mListener.onGetLocationSuccess();
            }
    }

    public interface LocationListener {
        void onGetLocationSuccess();

        void onGetLocationFailed();

        void onGetLatLon(LocationBean mLastLocation);
    }
}
